package uy.edu.um.ltic.server.persistence;

import static org.junit.Assert.*;

import java.sql.Timestamp;

import org.junit.Test;

import uy.edu.um.ltic.exception.DataBaseException;

public class testingAmountOfWords {

	@Test
	public void test() {
		/*
		 * Timestamp(int year, int month, int date, int hour, int minute, int
		 * second, int nano) year - the year minus 1900 month - 0 to 11 date - 1
		 * to 31 hour - 0 to 23 minute - 0 to 59 second - 0 to 59 nano - 0 to
		 * 999,999,999
		 */
		MessageDAOMgt oMessage = MessageDAOFactory.getInstance()
				.getMessageDAOMgt();
		@SuppressWarnings("deprecation")
		Timestamp oDate = new Timestamp(114, 0, 5, 0, 0, 0, 0);
		@SuppressWarnings("deprecation")
		Timestamp oDate2 = new Timestamp(114, 10, 15, 11, 33, 53, 0);
		@SuppressWarnings("deprecation")
		Timestamp oDate3 = new Timestamp(114, 10, 15, 11, 33, 58, 0);
		try {
			assertEquals(
					oMessage.getAmountOfWordsWritten(2, oDate,
							new Timestamp(System.currentTimeMillis())), 2);
			assertEquals(
					oMessage.getAmountOfWordsWritten(1, oDate,
							new Timestamp(System.currentTimeMillis())), 7);
			assertEquals(
					oMessage.getAmountOfWordsWritten(5, oDate,
							new Timestamp(System.currentTimeMillis())), 7);
			assertEquals(
					oMessage.getAmountOfWordsWritten(6, oDate,
							new Timestamp(System.currentTimeMillis())), 8);
			assertEquals(oMessage.getAmountOfWordsWritten(1, oDate2, new Timestamp(
					System.currentTimeMillis())), 3);
			assertEquals(oMessage.getAmountOfWordsWritten(2, oDate2,
							new Timestamp(System.currentTimeMillis())), 0);
			assertEquals(oMessage.getAmountOfWordsWritten(5, oDate2, oDate3), 5);
			assertEquals(oMessage.getAmountOfWordsWritten(6, oDate2, oDate3), 4);
		} catch (DataBaseException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
			
	}

}
